package com.lanou.projecta;

import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;

import com.lanou.projecta.me.*;
import com.lanou.projecta.me.MeFragment;
import com.lanou.projecta.news.NewsFragment;
import com.lanou.projecta.read.*;
import com.lanou.projecta.read.ReadFragment;
import com.lanou.projecta.topic.*;
import com.lanou.projecta.topic.TopicFragment;
import com.lanou.projecta.tv.*;
import com.lanou.projecta.tv.TvFragment;

public class MainActivity extends AppCompatActivity {
    private TabHost tabHost;
    private android.support.v4.app.FragmentManager fm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tabHost = (TabHost) findViewById(android.R.id.tabhost);
        tabHost.setup();
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("新闻").setContent(R.id.tab_news));
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("阅读").setContent(R.id.tab_read));
        tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("视听").setContent(R.id.tab_tv));
        tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator("话题.").setContent(R.id.tab_topic));
        tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("我.").setContent(R.id.tab_me));
        fm = getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.tab_news,new NewsFragment());
        transaction.replace(R.id.tab_read,new ReadFragment());
        transaction.replace(R.id.tab_tv,new TvFragment());
        transaction.replace(R.id.tab_topic,new TopicFragment());
        transaction.replace(R.id.tab_me,new MeFragment());
        transaction.commit();
    }
}
